Book Contents

Example: Write expressions

In this example, the operator regulates the speed of a conveyor belt by entering a value in feet or meters per second. When the operator enters the value in feet per second, the value is passed to the data source without conversion. When the operator enters the value in meters per second, the value is converted to feet per second before being passed to the data source.

The operator first indicates whether the value is in feet or meters by pushing a maintained push button. The push button has one state corresponding to feet per second, and the other state to meters per second. A tag called feet_or_meters is assigned to the maintained push button’s Value control.

Then the operator enters the value in a numeric pop-up keypad. The "?" character is the placeholder for the value the operator enters.

Here is the write expression assigned to the numeric input enable button’s Optional Expression control:

IF feet_or_meters == 0 THEN
?
ELSE
? * 3.281

The application writes the result of the expression to the Value control assigned to the numeric input enable button.

See also

About expressions

Write expressions